package com.yugao.fintech.antelope.infra.file.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * 文件模块工具类

 */
public class FileUtils {
    private static final List<String> illegalFileStrList = new ArrayList<>();

    static {
        illegalFileStrList.add("../");
        illegalFileStrList.add("./");
        illegalFileStrList.add("..\\");
        illegalFileStrList.add(".\\");
        illegalFileStrList.add("\\..");
        illegalFileStrList.add("\\.");
        illegalFileStrList.add("..");
        illegalFileStrList.add("...");
    }

    /**
     * 检查文件名是否合规
     * @param fileName 文件名
     * @return 合规结果,true:不合规，false:合规
     */
    public static boolean isIllegalFileName(String fileName){
        for (String str: illegalFileStrList){
            if(fileName.contains(str)){
                return true;
            }
        }
        return false;
    }
}
